package com.ljx.funchat.chat.service.adapter;

import com.ljx.funchat.chat.domain.entity.Redbag;
import com.ljx.funchat.chat.domain.entity.RedbagRecord;
import com.ljx.funchat.chat.domain.entity.msg.RedBagMsgDTO;
import com.ljx.funchat.chat.domain.enums.MessageTypeEnum;
import com.ljx.funchat.chat.domain.vo.req.ChatMessageReq;
import com.ljx.funchat.chat.domain.vo.req.RedbagSendReq;

public class RedbagAdapter {
    public static Redbag buildRedbagSave(Long uid, RedbagSendReq req) {
        return Redbag.builder()
                .money(req.getMoney())
                .desc(req.getDesc())
                .number(req.getNumber())
                .roomId(req.getRoomId())
                .uid(uid)
                .finalMoney(req.getMoney())
                .finalNumber(req.getNumber())
                .build();
    }

    public static ChatMessageReq buildRedbagSendReq(Redbag redbag) {
        return ChatMessageReq.builder()
                .roomId(redbag.getRoomId())
                .msgType(MessageTypeEnum.REDBAG.getType())
                .body(new RedBagMsgDTO(redbag.getId(), redbag.getDesc(), redbag.getNumber(), true, false))
                .build();
    }

    public static RedbagRecord buildRedbagRecordSave(Long uid, Long redbagId, Integer randomMoney) {
        return RedbagRecord.builder()
                .money(randomMoney)
                .uid(uid)
                .redbagId(redbagId)
                .build();
    }

    public static ChatMessageReq buildRedbagObtainReq(Redbag redbag) {
        return ChatMessageReq.builder()
                .roomId(redbag.getRoomId())
                .msgType(MessageTypeEnum.REDBAG.getType())
                .body(new RedBagMsgDTO(redbag.getId(), redbag.getDesc(), redbag.getNumber(), true, false))
                .build();
    }
}
